<!DOCTYPE html>
<html lang="en">

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<meta name="description" content="">
		<meta name="author" content="Mosaddek">
		<meta name="keyword" content="FlatLab, Dashboard, Bootstrap, Admin, Template, Theme, Responsive, Fluid, Retina">
		<link rel="shortcut icon" href="img/favicon.html">

		<title>查看用户</title>

		<!-- Bootstrap core CSS -->
		<link href="css/bootstrap.min.css" rel="stylesheet">
		<link href="css/bootstrap-reset.css" rel="stylesheet">
		<!--external css-->
		<link href="assets/font-awesome/css/font-awesome.css" rel="stylesheet" />
		<!-- Custom styles for this template -->
		<link href="css/style.css" rel="stylesheet">
		<link href="css/style-responsive.css" rel="stylesheet" />

		<!-- HTML5 shim and Respond.js IE8 support of HTML5 tooltipss and media queries -->
		<!--[if lt IE 9]>
      <script src="js/html5shiv.js"></script>
      <script src="js/respond.min.js"></script>
    <![endif]-->
		<script src="js/jquery-1.8.3.min.js"></script>
		<script src="js/json2.js"></script>
		<script type="text/javascript">
			function querys() {
				var ownerName = $("#ownerName").val(),
					condition = $("#condition").val();
				var datalist = {
					'username': ownerName,
					'state': condition,
					'start': 0,
					'count': 10
				};
				var t = JSON.stringify(datalist);
				$.ajax({
					async: false,
					url: 'user_querys.action',
					type: 'POST',
					dataType: 'json',
					data: "data=" + t,

					success: function(data) {
						//var datas = JSON.parse(data); //将数据转换成json类型，可以把data用alert()输出出来看看到底是什么样的结构
						//得到的d是一个形如{"key":"value","key1":"value1"}的数据类型，然后取值出来   eval("(" + data + ")")
						//alert(d.data.name);
						if(data.code == 0) {
							alert(data.data);
							console.log('请求出错');
							return false;
						}
						//取出datas中包含的数组data并遍历取值
						var arr = data.data;
						sessionStorage.setItem("userList", JSON.stringify(arr));
						var t = _.template($("#temp").html());
						$("#content").html(t(arr));
					}

					/* error: function() {
							alert(arguments[1]);
							//alert("用户名或密码有误，请重新输入！");
						} //这里不要加"," */

				})
			}

			//删除对应用户
			function del() {
				var r=confirm("确定要从数据库中删除该记录？")			
					if(r){
						var data = JSON.parse(sessionStorage.getItem("userList"));
						var dataList = [];
						var j = 0;
						$("input:checkbox[name='box']:checked").each(function(){							   
							   var i = $(this).val();							  
							   var username = data[i].username;
							   var temp = {"username":username};						   							   			       
							   dataList[j] = temp;
							   j=j+1;	 		       						       				       	       				       
						})
						var dd = JSON.stringify(dataList);
					    //alert(dd);
						$.ajax({
							url: 'user_delete.action',
							type: 'POST',
							dataType: 'json',
							data: "data=" + dd,

							success: function(data) {
								alert(data.data);
								console.log('success');
							},

							error: function(data) {
								alert(data.data);
							}
						}) 		
					} 				
			} 
		</script>
		<script type="text/template" id="temp">
			<% _.each(obj, function (index,item) { %>
			<tr class="odd gradeX">
				<td><input type="checkbox" class="checkboxes" value="<%=item %>" name="box" /></td>
				<td class="hidden-phone">
					<%=index.id %>
				</td>
				<td class="hidden-phone">
					<%=index.name %>
				</td>
				<td class="hidden-phone">
					<%=index.sex %>
				</td>
				<td class="hidden-phone">
					<%=index.state %>
				</td>
				<td class="hidden-phone">
					<%=index.authority %>
				</td>
                <td class="hidden-phone">
					<%=index.date %>
				</td>
				<td class="hidden-phone">
					<button class="btn btn-primary btn-xs"><a href="ownerManagement.html"><i class="icon-pencil"></i></a></button>
					<button class="btn btn-danger btn-xs" onclick="del();return false;"><i class="icon-trash "></i></button></td>
			</tr>
			<% }); %>
		</script>
	</head>

	<body>

		<section id="container" class="">
			<!--header start-->
			<header class="header white-bg">
				<div class="sidebar-toggle-box">
					<div data-original-title="" data-placement="right" class="icon-reorder tooltips"></div>
				</div>
				<!--logo start-->
				<a href="#" class="logo">车辆<span>管理系统</span></a>
				<!--logo end-->

				<div class="top-nav ">
					<ul class="nav pull-right top-menu">
						<li><input type="text" class="form-control search" placeholder="Search"></li>
						<!-- user login dropdown start-->
						<li class="dropdown">
							<a data-toggle="dropdown" class="dropdown-toggle" href="#"> <img alt="" src="img/avatar1_small.jpg"> <span class="username">嘿嘿</span>
								<b class="caret"></b>
							</a>
							<ul class="dropdown-menu extended logout">
								<div class="log-arrow-up"></div>
								<li>
									<a href="#"><i class=" icon-suitcase"></i>个人资料</a>
								</li>
								<li>
									<a href="#"><i class="icon-cog"></i>设置</a>
								</li>
								<li>
									<a href="#"><i class="icon-bell-alt"></i> 通知</a>
								</li>
								<li>
									<a href="login.html"><i class="icon-key"></i> 退出</a>
								</li>
							</ul>
						</li>
						<!-- user login dropdown end -->
					</ul>
				</div>
			</header>
			<!--header end-->
			<!--sidebar start-->
			<aside>
				<div id="sidebar" class="nav-collapse ">
					<!-- sidebar menu start-->
					<ul class="sidebar-menu">
						<li class="">
							<a class="" href="index.html"> <i class="icon-dashboard"></i> <span>首页</span>
							</a>
						</li>
						<li class="sub-menu">
							<a href="javascript:;" class=""> <i class="icon-book"></i> <span>车辆基本信息管理</span> <span class="arrow"></span>
							</a>
							<ul class="sub">
								<li>
									<a class="" href="carList.html">车辆列表</a>
								</li>
								<li>
									<a class="" href="addCar.html">新增车辆</a>
								</li>
							</ul>
						</li>
						<li class="sub-menu">
							<a href="javascript:;" class=""> <i class="icon-cogs"></i> <span>车主信息管理</span> <span class="arrow"></span>
							</a>
							<ul class="sub">
								<li>
									<a class="" href="carOwnerList.html">车主列表</a>
								</li>
								<li>
									<a class="" href="addCarOwner.html">新增车主</a>
								</li>
							</ul>
						</li>
						<li class="sub-menu">
							<a href="javascript:;" class=""> <i class="icon-tasks"></i> <span>车辆管理费</span> <span class="arrow"></span>
							</a>
							<ul class="sub">
								<li>
									<a class="" href="feeList.html">费用列表</a>
								</li>
								<li>
									<a class="" href="chargeMoney.html">收取管理费</a>
								</li>
							</ul>
						</li>
						<li class="sub-menu">
							<a href="javascript:;" class=""> <i class="icon-th"></i> <span>车辆变更管理</span> <span class="arrow"></span>
							</a>
							<ul class="sub">
								<li>
									<a class="" href="carTransferList.html">车辆变更列表</a>
								</li>
								<li>
									<a class="" href="addCarTransfer.html">新增车辆变更</a>
								</li>
							</ul>
						</li>
						<li class="sub-menu active">
							<a href="javascript:;" class="">
								<i class="icon-glass"></i> <span>系统管理</span> <span class="arrow"></span>
							</a>
							<ul class="sub">
								<li class="active">
									<a class="" href="queryOwner.html">查看用户</a>
								</li>
								<li>
									<a class="" href="ownerManagement.html">用户管理</a>
								</li>
								<li>
									<a class="" href="quit.html">安全退出</a>
								</li>
							</ul>
						</li>
						<li>
							<a class="" href="login.html"> <i class="icon-user"></i>
								<span>登录</span>
							</a>
						</li>
					</ul>
					<!-- sidebar menu end-->
				</div>
			</aside>
			<!--sidebar end-->
			<!--main content start-->
			<section id="main-content">
				<section class="wrapper">
					<!-- page start-->
					<div class="row">
						<div class="col-lg-12">
							<section class="panel">
								<header class="panel-heading"> 用户查找 </header>
								<div class="panel-body bio-graph-info">
									<form role="form" class="form-horizontal" action="">
										<div class="form-group">
											<label class="col-lg-1 control-label" for="carNumber">用户名</label>
											<div class="col-lg-2">
												<input type="text" class="form-control" id="ownerName" />
												<!--  -->
											</div>
											<label class="col-lg-1 control-label" for="carNumber">状态</label>
											<div class="col-lg-2">
												<select name="sample_1_length" aria-controls="sample_1" class="form-control" id="condition">
													<option value="全部" selected="selected">全部</option>
													<option value="可用">可用</option>
													<option value="禁用">禁用</option>
												</select>
											</div>
											<div class="col-lg-5">
												<button class="btn btn-shadow btn-primary" onclick="querys(); return false;">查询</button>
											</div>
										</div>
									</form>
								</div>

								<table class="table table-striped border-top" id="sample_1">
									<!--id="sample_1" -->
									<thead>
										<tr>
											<th style="width: 8px;"><input type="checkbox" class="group-checkable" data-set="#sample_1 .checkboxes" /></th>
											<th>登录编号</th>
											<th class="hidden-phone">姓名</th>
											<th class="hidden-phone">性别</th>
											<th class="hidden-phone">状态</th>
											<th class="hidden-phone">角色</th>
											<th class="hidden-phone">创建时间</th>
											<!-- <th class="hidden-phone">登记时间</th> -->
											<th class="hidden-phone">操作</th>
										</tr>
									</thead>
									<tbody id="content">
									    <!-- 此处插入返回的用户数据 -->
										<!-- <tr class="odd gradeX">
										<td><input type="checkbox" class="checkboxes" value="1" /></td>
										<td class="hidden-phone">001</td>
										<td class="hidden-phone">张三</td>
										<td class="hidden-phone">男</td>
										<td class="hidden-phone">可用</td>
										<td class="hidden-phone">管理员</td>
										<td class="hidden-phone">2016-10-10</td>

										<td class="hidden-phone">33</td>
										<td class="hidden-phone">
											<button class="btn btn-primary btn-xs">
												<i class="icon-pencil"></i>
											</button>
											<button class="btn btn-danger btn-xs" onclick='alert("是否确定要删除该用户")'>
												<i class="icon-trash "></i>
											</button>
										</td>
									</tr> -->
									</tbody>
								</table>
							</section>
						</div>
					</div>
					<!-- page end-->
				</section>
			</section>
			<!--main content end-->
		</section>

		<!-- js placed at the end of the document so the pages load faster -->
		<script src="js/jquery.js"></script>
		<script src="js/bootstrap.min.js"></script>
		<script src="js/jquery.scrollTo.min.js"></script>
		<script src="js/jquery.nicescroll.js" type="text/javascript"></script>
		<script type="text/javascript" src="assets/data-tables/jquery.dataTables.js"></script>
		<script type="text/javascript" src="assets/data-tables/DT_bootstrap.js"></script>

		<!--common script for all pages-->
		<script src="js/common-scripts.js"></script>

		<!--script for this page only-->
		<script src="js/dynamic-table.js"></script>
		<script src="js/Underscore.js"></script>
		
		<script src="js/json2.js"></script>

	</body>

</html>